package com.kefu.call.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.kefu.call.model.CallInnumber;
import com.kefu.call.service.CallInnumberService;
import com.kefu.call.vo.CallInnumberSearchVo;
import com.kefu.common.controller.AbstractBaseController;
import com.kefu.common.result.Result;
import com.kefu.common.result.ResultGenerator;
import com.kefu.common.vo.DetailVo;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

@Api(tags = "呼入号码")
@RestController
@RequestMapping("call/innumber")
public class CallInnumberController extends AbstractBaseController {

    @Autowired
    private CallInnumberService callInnumberService;

    @PostMapping("/list")
    @ApiOperation(value = "查询呼入号码", notes = "查询呼入号码")
    public Result<Page<CallInnumber>> list(@Validated @RequestBody CallInnumberSearchVo search) {

        Page<CallInnumber> page = callInnumberService.searchLambdaPage(search);
        return ResultGenerator.genSuccessResult(page);
    }
    
    @PostMapping("/availableList")
    @ApiOperation(value = "查询使用呼入号码", notes = "查询可以使用的呼入号码,传递参数为ivrId,新增的时候可以传字符串NULL")
    public Result<List<CallInnumber>> availableList(@Validated @RequestBody DetailVo detailVo) {
    	
    	List<CallInnumber> list = callInnumberService.selectAvailableList(detailVo);
    	return ResultGenerator.genSuccessResult(list);
    }
}
